import { defineStore } from 'pinia'
import { store } from '/@/store'
import type { AxiosResponse } from 'axios'
import type { Res } from '/@/tool/Res'
import type { Param } from '/@/tool/Param'
import type { DataExportAO } from '/@/model/cn/core/tool/ao/DataExportAO'

import taskExpressionParamService from '/@/api/cn/core/kpis/taskExpressionParamService'

import type { TaskExpressionParam } from '/@/model/cn/core/kpis/eo/TaskExpressionParam'
import type { TaskExpressionParamQO } from '/@/model/cn/core/kpis/qo/TaskExpressionParamQO'
import type { TaskExpressionParamVO } from '/@/model/cn/core/kpis/vo/TaskExpressionParamVO'

interface TaskExpressionParamState {
}

export const useTaskExpressionParamStore = defineStore({
  id: 'taskExpressionParam',
  state: (): TaskExpressionParamState => ({
  }),
  getters: {
  },
  actions: {
    save(param: Param<TaskExpressionParam>): Promise<Res<TaskExpressionParam>> {
      return new Promise<Res<TaskExpressionParam>>((resolve, reject) => {
        taskExpressionParamService.save(param).then((res: AxiosResponse<Res<TaskExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    saveBatch(param: Param<TaskExpressionParam>): Promise<Res<TaskExpressionParam>> {
      return new Promise<Res<TaskExpressionParam>>((resolve, reject) => {
        taskExpressionParamService.saveBatch(param).then((res: AxiosResponse<Res<TaskExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    update(param: Param<TaskExpressionParam>): Promise<Res<TaskExpressionParam>> {
      return new Promise<Res<TaskExpressionParam>>((resolve, reject) => {
        taskExpressionParamService.update(param).then((res: AxiosResponse<Res<TaskExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    updateBatch(param: Param<TaskExpressionParam>): Promise<Res<TaskExpressionParam>> {
      return new Promise<Res<TaskExpressionParam>>((resolve, reject) => {
        taskExpressionParamService.updateBatch(param).then((res: AxiosResponse<Res<TaskExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    remove(param: Param<TaskExpressionParam>): Promise<Res<TaskExpressionParam>> {
      return new Promise<Res<TaskExpressionParam>>((resolve, reject) => {
        taskExpressionParamService.remove(param).then((res: AxiosResponse<Res<TaskExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    removeBatch(param: Param<TaskExpressionParam>): Promise<Res<TaskExpressionParam>> {
      return new Promise<Res<TaskExpressionParam>>((resolve, reject) => {
        taskExpressionParamService.removeBatch(param).then((res: AxiosResponse<Res<TaskExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    count(param: Param<TaskExpressionParamQO>): Promise<Res<TaskExpressionParam>> {
      return new Promise<Res<TaskExpressionParam>>((resolve, reject) => {
        taskExpressionParamService.count(param).then((res: AxiosResponse<Res<TaskExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pk(param: Param<TaskExpressionParamQO>): Promise<Res<TaskExpressionParam>> {
      return new Promise<Res<TaskExpressionParam>>((resolve, reject) => {
        taskExpressionParamService.pk(param).then((res: AxiosResponse<Res<TaskExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    query(param: Param<TaskExpressionParamQO>): Promise<Res<TaskExpressionParam>> {
      return new Promise<Res<TaskExpressionParam>>((resolve, reject) => {
        taskExpressionParamService.query(param).then((res: AxiosResponse<Res<TaskExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    paging(param: Param<TaskExpressionParamQO>): Promise<Res<TaskExpressionParam>> {
      return new Promise<Res<TaskExpressionParam>>((resolve, reject) => {
        taskExpressionParamService.paging(param).then((res: AxiosResponse<Res<TaskExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    countVo(param: Param<TaskExpressionParamQO>): Promise<Res<TaskExpressionParamVO>> {
      return new Promise<Res<TaskExpressionParamVO>>((resolve, reject) => {
        taskExpressionParamService.countVo(param).then((res: AxiosResponse<Res<TaskExpressionParamVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pkVo(param: Param<TaskExpressionParamQO>): Promise<Res<TaskExpressionParamVO>> {
      return new Promise<Res<TaskExpressionParamVO>>((resolve, reject) => {
        taskExpressionParamService.pkVo(param).then((res: AxiosResponse<Res<TaskExpressionParamVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    queryVo(param: Param<TaskExpressionParamQO>): Promise<Res<TaskExpressionParamVO>> {
      return new Promise<Res<TaskExpressionParamVO>>((resolve, reject) => {
        taskExpressionParamService.queryVo(param).then((res: AxiosResponse<Res<TaskExpressionParamVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pagingVo(param: Param<TaskExpressionParamQO>): Promise<Res<TaskExpressionParamVO>> {
      return new Promise<Res<TaskExpressionParamVO>>((resolve, reject) => {
        taskExpressionParamService.pagingVo(param).then((res: AxiosResponse<Res<TaskExpressionParamVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    dataImport(param: Param<string>): Promise<Res<TaskExpressionParam>> {
      return new Promise<Res<TaskExpressionParam>>((resolve, reject) => {
        taskExpressionParamService.dataImport(param).then((res: AxiosResponse<Res<TaskExpressionParam>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    dataExport(param: Param<DataExportAO<TaskExpressionParamQO>>): Promise<Res<string>> {
      return new Promise<Res<string>>((resolve, reject) => {
        taskExpressionParamService.dataExport(param).then((res: AxiosResponse<Res<string>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
  },
})

export function useTaskExpressionParamStoreWithout() {
  return useTaskExpressionParamStore(store)
}
